package com.example.floatingpopulation.controller;

import com.example.floatingpopulation.common.Result;
import com.example.floatingpopulation.controller.request.AuxiliaryOfficePageRequest;
import com.example.floatingpopulation.controller.request.TemporaryResidencePermitPageRequest;
import com.example.floatingpopulation.entity.AuxiliaryOffice;
import com.example.floatingpopulation.entity.CommunityAssistance;
import com.example.floatingpopulation.entity.TemporaryResidencePermit;
import com.example.floatingpopulation.service.AuxiliaryOfficeService;
import com.example.floatingpopulation.service.TemporaryResidencePermitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/auxiliaryOffice")
public class AuxiliaryOfficeController {
    @Autowired
    AuxiliaryOfficeService auxiliaryOfficeService;


    @PostMapping("/save")
    public Result<String> save(@RequestBody AuxiliaryOffice obj) {
        auxiliaryOfficeService.save(obj);
        return Result.success();
    }

    @PutMapping("/update")
    public Result<String> update(@RequestBody AuxiliaryOffice obj) {
        auxiliaryOfficeService.update(obj);
        return Result.success();
    }


    @DeleteMapping("/delete/{id}")
    public Result<String> delete(@PathVariable Integer id){
        auxiliaryOfficeService.deleteById(id);
        return Result.success();
    }


    @GetMapping("/list")
    public Result<String> list(){
        List<AuxiliaryOffice> list = auxiliaryOfficeService.list();
        return Result.success(list);
    }


    @GetMapping("/page")
    public Result<String> page(AuxiliaryOfficePageRequest pageRequest){
        return Result.success(auxiliaryOfficeService.page(pageRequest));
    }

    @PutMapping("/updateStatus")
    public Result updateStatus(@RequestBody AuxiliaryOffice obj) {
        auxiliaryOfficeService.updateStatus(obj);
        return Result.success();
    }
}
